load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library")

oncall("scm_client_infra")

cpp_library(
    name = "interface",
    srcs = ["PrivHelper.cpp"],
    headers = ["PrivHelper.h"],
    deps = [
        "//folly:file",
        "//folly/futures:core",
        "//folly/io/async:async_base",
    ],
    exported_deps = [
        "//folly:network_address",
        "//folly:portability",
        "//folly:range",
    ],
)

cpp_library(
    name = "flags",
    srcs = ["PrivHelperFlags.cpp"],
    headers = ["PrivHelperFlags.h"],
    exported_external_deps = [
        "gflags",
    ],
)

cpp_library(
    name = "conn",
    srcs = ["PrivHelperConn.cpp"],
    headers = ["PrivHelperConn.h"],
    deps = [
        "//eden/common/utils:bug",
        "//eden/common/utils:system_error",
        "//eden/common/utils:throw",
        "//folly:demangle",
        "//folly:exception",
        "//folly:file",
        "//folly:file_util",
        "//folly:network_address",
        "//folly/futures:core",
        "//folly/logging:logging",
        "//folly/portability:sockets",
        "//folly/portability:unistd",
    ],
    exported_deps = [
        "fbsource//third-party/fmt:fmt",
        ":interface",
        "//eden/common/utils:io",
        "//folly:range",
        "//folly/io:iobuf",
    ],
)

cpp_library(
    name = "server",
    srcs = [
        "PrivHelperServer.cpp",
        "PrivHelperServerSanityCheck.cpp",
    ],
    headers = ["PrivHelperServer.h"],
    os_deps = [
        (
            "macos",
            [
                "fbsource//third-party/osxfuse:osxfuse",
                "fbsource//third-party/toolchains/macos:CoreFoundation",
                "fbsource//third-party/toolchains/macos:IOKit",
            ],
        ),
    ],
    deps = [
        ":nfs_rpc",
        "//eden/common/utils:errno_utils",
        "//eden/common/utils:fsdetect",
        "//eden/common/utils:path",
        "//eden/common/utils:sysctl_util",
        "//eden/common/utils:throw",
        "//eden/fs/privhelper/priority:process_priority",
        "//folly:conv",
        "//folly:exception",
        "//folly:expected",
        "//folly:file",
        "//folly:file_util",
        "//folly:network_address",
        "//folly:string",
        "//folly:utility",
        "//folly/init:init",
        "//folly/io:iobuf",
        "//folly/io/async:async_base",
        "//folly/logging:init",
        "//folly/logging:logging",
        "//folly/portability:unistd",
        "//folly/system:thread_name",
    ],
    exported_deps = [
        ":conn",
        "//eden/common/utils:io",
        "//eden/common/utils:process",
    ],
    external_deps = [
        ("boost", None, "boost_algorithm"),
    ],
)

cpp_library(
    name = "privhelper",
    srcs = [
        "PrivHelperImpl.cpp",
    ],
    headers = [
        "PrivHelperImpl.h",
    ],
    deps = [
        ":conn",
        ":flags",
        ":interface",
        "//eden/common/utils:bug",
        "//eden/common/utils:io",
        "//eden/common/utils:process",
        "//eden/common/utils:user_info",
        "//eden/fs/utils:eden_error",
        "//folly:exception",
        "//folly:expected",
        "//folly:file",
        "//folly:file_util",
        "//folly:network_address",
        "//folly:synchronized",
        "//folly/futures:core",
        "//folly/io:iobuf",
        "//folly/io/async:async_base",
        "//folly/logging:logging",
        "//folly/portability:sys_types",
        "//folly/portability:unistd",
    ],
    exported_deps = [
        "//eden/common/utils:path",
    ],
    exported_external_deps = [
        "gflags",
    ],
)

cpp_library(
    name = "nfs_rpc",
    srcs = ["NfsMountRpc.cpp"],
    headers = ["NfsMountRpc.h"],
    exported_deps = [
        "//eden/fs/nfs/xdr:xdr",
    ],
)
